/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_branch_action.h

	$Header: /heroes4/script_branch_action.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_BRANCH_ACTION_H_INCLUDED )
#define SCRIPT_BRANCH_ACTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <iosfwd>

#include "abstract_script_action.h"
#include "owned_ptr.h"

// --------------------------------------------------------------------------
// t_script_branch_action class
// --------------------------------------------------------------------------

class t_script_branch_action : public t_abstract_script_action
{
public:
	// Types
	typedef t_abstract_script_action	t_subaction;
	typedef t_counted_ptr<t_subaction>	t_subaction_ptr;

	// Member functions
	t_subaction const &	get_true_subaction() const;
	t_subaction const &	get_false_subaction() const;
	virtual bool		read( std::streambuf &	stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf &	stream ) const;

private:
	// Data members
	t_subaction_ptr					m_true_subaction_ptr;
	t_subaction_ptr					m_false_subaction_ptr;
};

// --------------------------------------------------------------------------
// t_script_branch_action inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_branch_action::t_subaction const &
t_script_branch_action::get_true_subaction() const
{
	assert( m_true_subaction_ptr.get() != 0 );
	return *m_true_subaction_ptr;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_branch_action::t_subaction const &
t_script_branch_action::get_false_subaction() const
{
	assert( m_false_subaction_ptr.get() != 0 );
	return *m_false_subaction_ptr;
}

#endif // !defined( SCRIPT_BRANCH_ACTION_H_INCLUDED )
